package com.example.interfaces;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;
import java.util.Date;


/**
 * ClassName: DeadLetterQueueConsumer
 * author: bob.ly
 * Version: 1.0.0
 * DateTime: 2021/07/26-17:28:00
 * Description:
 */
@Slf4j
@Component
public class DeadLetterQueueConsumer {

    /**
     * 消费者监听死信队列
     */
    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) throws UnsupportedEncodingException {
        String msg = new String(message.getBody(), "UTF-8");
        log.info("当前时间：{},收到死信队列信息{}", new Date().toString(), msg);
    }
}
